package cn.tedu.spring.bean;

import cn.tedu.spring.bean.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserService {
    /**
     * AutoWired注解 注入对象或接口类型的数据 一般都是写在属性上
     * 添加位置:1.属性上
     * 2.set方法上
     * 3.构造方法上
     * required参数
     * true [默认]装配失败会抛异常
     * flase 不抛异常
     * */

    public UserDao userDao;
    @Autowired
    public UserService(UserDao userDao) {
        this.userDao = userDao;
    }


    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    @Override
    public String toString() {
        return "UserService{" +
                "userDao=" + userDao +
                '}';
    }
}
